/*
 * @lc app=leetcode.cn id=867 lang=cpp
 *
 * [867] 转置矩阵
 */

// @lc code=start
class Solution {
public:
/*
    vector<vector<int>> transpose(vector<vector<int>>& matrix) {
        vector<vector<int>> res;
        for(int i = 0; i < matrix[0].size();i++)
        {
            res.push_back(vector<int> {});
            for(int j = 0 ;j < matrix.size() ;j++)
            {
                res[i].push_back(matrix[j][i]);
            }
        }
        return res;
    }
    */
   vector<vector<int>> transpose(vector<vector<int>>& matrix) {
        int m = matrix.size(), n = matrix[0].size();
        vector<vector<int>> transposed(n, vector<int>(m));
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                transposed[j][i] = matrix[i][j];
            }
        }
        return transposed;
    }
};
// @lc code=end

